import {createRouter, createWebHistory} from 'vue-router';

import Layout from '@/layout/index.vue';

const routes = [
    {
        path: '/',
        meta: {
            title: '平台首页',
            icon: 'home-outlined',
            key: 'homepage',
            requireAuth: true
        },
        component: Layout,
        children: [
            {
                path: '',
                component: () => import('@/views/index.vue')
            }
        ]
    },
    {
        path: '/login',
        meta: {
            title: '用户登陆',
            icon: 'login-outlined',
            key: 'user:login'
        },
        component: () => import('@/views/login.vue')
    },
    // 首页跳转homepage
    {
        path: '/:lang(.*)',
        redirect: '/'
    }
];

export default createRouter({
    history: createWebHistory(),
    fallback: false,
    routes,
    scrollBehavior: to => {
        if (to.hash) {
            return {el: to.hash, top: 80, behavior: 'auto'};
        }
    }
});